
<?
$request = $_REQUEST['frame'];
if ($request == "cc")
	$text = "&nbsp;&nbsp;&nbsp;Chứng chỉ";
$code = isset($_REQUEST['code']) ? $_REQUEST['code'] : "dtcc";
if ($code == "dtcc")
{
	$cWhere = "code = '$code'";
	
	$row = getRecord("tbl_content",$cWhere);
?>
	<div class="timedetail"><?=$text." - ".date("d/m/Y", $row['date_added'])?></div>
	<div class="titledetail"><?=$row['name']?></div>
	<div class="content">
		<?=$row['detail']?>
	</div>
<?
}
else if ($code == "caccc")
{	
	$code = "vn_".$code;
	$per_page =5;
	$p = isset ( $_GET["p"] ) ? intval ( $_GET["p"] ) : 0; 
	$cWhere = " and parent = (select id from tbl_content_category where code='$code')";
	$sql = "select * from tbl_content where status=0 $cWhere order by sort,date_added desc limit ".$per_page*$p.",".$per_page;
	//echo $sql;
	$result = @mysql_query($sql,$conn);
	$num=mysql_num_rows($result);
	?>
	<div class="timedetail">Ngày <?=date("d/m/Y")?></div>
	<div class="titledetail">Thi Chứng chỉ Quốc tế</div>
	<div class="content">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tbstruct">
	  <tbody>
	   
		<tr>
		  <th align="right" width="5%" class="bluem">#.</th>
		  <th class="bluem">Tiêu đề của danh mục</th>
		  <th align="center" width="5%" nowrap="nowrap" class="bluem">Số truy cập</th>
		</tr>
	<?
	if($num==0){?>
	
	<tr><td align="center"><font color="#FF0000" size="2">Thông tin đang cập nhật ...</font></td></tr>
	
	<? }
	else{?>
	
	<? 
	$count = 0;
	while($row=mysql_fetch_assoc($result))
	{
		$count++;
		if ($count % 2 == 1)
			$data_style = "blue";
		else
			$data_style = "bluelight";
	?>
	  <tr>
		<td  align="right" class="<?=$data_style?>"><?=$count?></td>
		<td class="<?=$data_style?>"> <a href="./?frame=cc&code=caccc&id=<?=$row['id']?>"> <?=$row["name"]?></a></td>
		<td align="center" class="<?=$data_style?>"></td>
	  </tr>	   
	<? 
	}?>

	   
	<? } ?>
	  </tbody>
	</table>	
	</div> 
		
	<?
	$total=countRecord("tbl_content","1=1 ".$cWhere);	//dem so luong record
	$number_of_page = ceil ( $total / $per_page );	//tong so trang
	//echo "so trang la:".$number_of_page;
	if ( $number_of_page > 0 )
	{
		$list_page = " <td> Trang $p / $number_of_page: </td>";
		
		$pre = "./?frame=".$_REQUEST['frame']."&code=caccc&p=".($p-1);
		if ($p >=1 )	//neu trang hien tai nho hon 2 thi ko co' ve truoc nua
			$list_page .= "<a title='Trang trước' href='".$pre."'><img width='12' height='12' border='0' align='bottom' src='Images/FirstPage.gif'></a>";
		for ( $i = $p -1 ; $i <= $p + 1; $i++ )	//chi hien thi 3 trang lien ke
		{		
			//neu trang hien tai thi in dam
			if ( $i == $p )
			{
				$list_page .= "  <a href=''><font color='red'><b>".$i."</b></font></a>  ";
			}
			else	//khong phai trang hien tai
			{
				if ($i >= 0 && $i < $number_of_page)
					$list_page .= "<a href=\"./?frame=".$_REQUEST['frame']."&code=caccc&p=$i\"> ".$i." </a>";
			}
			
		}
		$next = "./?frame=".$_REQUEST['frame']."&code=caccc&p=".($p+1);
		if ($p < $number_of_page - 1)
			$list_page .= "<a title='Trang sau' href='".$next."'><img width='12' height='12' border='0' align='bottom' src='Images/LastPage.gif'></a>";
	}

print <<<EOF
<div class="pages">
{$list_page}
</div>
EOF;

	?>
<?}?>
